package com.dongyimai.oauth.interceptor;

import com.dongyimai.oauth.token.AdminToken;
import feign.RequestInterceptor;
import feign.RequestTemplate;
import org.springframework.context.annotation.Configuration;

@Configuration
public class FeignInterceptor implements RequestInterceptor {

    /**
     * 该方法在feign远程调用时 使用
     * @param requestTemplate
     */
    @Override
    public void apply(RequestTemplate requestTemplate) {
        String token = AdminToken.getAdminToken();
        requestTemplate.header("Authorization","bearer " + token);
    }
}
